<template>
<div>
   <!--按钮-->
    <div class="btns">
      <el-form size="small" inline style="text-align: center">
        <el-form-item>
          <el-input placeholder="请输入ID" v-model="param.roleId"></el-input>
          <template slot="append"></template>
        </el-form-item>
        <el-form-item>
         <el-button size="small" type="primary" @click="loadbaseRolePrivilege" icon="el-icon-search" plain>搜索</el-button>
          <el-button type="primary" size="small" @click="toAddHandler" plain><i class="el-icon-edit"> 新增</i></el-button>
        </el-form-item>
      </el-form>
    </div>
   <!--/按钮-->
   <!--表格-->

   <el-table size="small" :data="baseRolePrivilege">
       <el-table-column type="index" :index="1" label="序号"></el-table-column>
   <el-table-column label="id" prop="id" align="center"></el-table-column>
   <el-table-column label="角色ID" prop="roleId" align="center"></el-table-column>
   <el-table-column label="权限ID" prop="privilegeId" align="center"></el-table-column>
   <el-table-column label="操作" width="100" align="center">
       <!--定制-插槽-->
       <template slot-scope="scope">
           <el-button type="text" size="mini" icon="el-icon-delete" @click="deleteHandler(scope.row)" >删除</el-button>
           <br>
           <el-button type="text" size="mini" icon="el-icon-edit" @click="editHandler(scope.row)" >修改</el-button >
       </template>
   </el-table-column>
</el-table>
   <!--/表格-->
 </div>
</template>
<script>
import {del, get} from '@/utils/request';
export default {
  // 页面数据
  data(){
    return {
    param: {},
     baseRolePrivilege:[],
    };
  },
methods:{
  // 修改事件处理函数
    editHandler(row){
      // 跳转到修改页面 （新增页面）
      // 携带当前行的数据
      this.$router.push({
        path:"/baseRolePrivilege/create",    //跳转的路由（前端）
        query:row   // 携带参数
      })
    },
 deleteHandler(row){
     this.$confirm("此操作将永久删除该数据，是否继续？","提示",{
         confirmButtonText:"确定",
         cancelButtonText:"取消",
         type:"warning",
     }).then(() => {
         let url = "http://8.131.68.179:9999/base_role_privilege/deleteByID";
         del(url, { id: row.id }).then((resp) => {
             this.$message({type:"success",message:resp.message});
             this.loadbaseRolePrivilege();
         });
 });
},
toAddHandler(){
    this.$router.push("/baseRolePrivilege/create");
},
loadbaseRolePrivilege(){
     let url = 'http://8.131.68.179:9999/base_role_privilege/select'
      get(url,this.param).then((resp) => {
        this.baseRolePrivilege = resp.data;
});
},
},
  // 页面渲染的时候会调用的函数
  created(){
    this.loadbaseRolePrivilege();
  },
};
  // 所有的方法
</script>
<style scoped>

</style>
